home *** CD-ROM | disk | FTP | other *** search
-
- /******************************************************************************
- * *
- * *
- ******************************************************************************/
-
-
- #include <windows.h>
- #include <mem.h>
- #include <uty00000.h>
- //#include <custcntl.h>
- #include <uty25001.h>
- #include <uty25002.h>
-
- #ifdef WIN32
-
- #define _loadds
-
- //
- // Common Dialogs
- // - Win32 dll has different name.
- // - GetProcAddress() is case sensitive.
- //
- #define szCommDlgName "comdlg32.dll"
- #define szCDDwLbSubclass "dwLBSubclass"
- #define szCDEditIntegerOnly "EditIntegerOnly"
-
- #define FValidLibHandle(hlib) ((hlib) != NULL)
-
- //
- // No concept of far in Win32.
- //
-
- #define MEMICMP memicmp
-
- //
- // Control IDs are LONG in Win32.
- //
-
- typedef LONG CTLID;
- #define GetControlId(hwnd) GetWindowLong(hwnd, GWL_ID)
-
- //
- // Send a color button message.
- //
-
- #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc ) \
- ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORBTN, (WPARAM) hdc, (LPARAM) hwnd))
-
- //
- // Send a color static message.
- //
-
- #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc ) \
- ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORSTATIC, (WPARAM) hdc, (LPARAM) hwnd))
-
- #else
-
-
- #define szCommDlgName "commdlg.dll"
- #define szCDDwLbSubclass "DWLBSUBCLASS"
- #define szCDEditIntegerOnly "EDITINTEGERONLY"
-
- #define FValidLibHandle(hlib) (( hlib ) > 32 )
-
- #define MEMICMP _fmemicmp
-
- typedef WORD CTLID;
- #define GetControlId( h ) GetWindowWord( h, GWW_ID )
-
- #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc ) \
- ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_BTN)))
-
- #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc ) \
- ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_STATIC)))
-
- #endif // WIN32
-
-
-
- // Index Color Table
- // WARNING: change mpicvSysColors if you change the icv order
- typedef WORD ICV;
-
- #define icvBtnHilite 0
- #define icvBtnFace 1
- #define icvBtnShadow 2
- #define icvBtnText 3
- #define icvWindow 4
- #define icvWindowText 5
- #define icvGrayText 6
- #define icvWindowFrame 7
- #define icvForceBlack 8
- #define icvForceLTGray 9
- #define icvForceDKGray 10
- #define icvForceWhite 11
- #define icvMax 12
- #define icvSysMax 8
-
- #define icvSysBrushMax 3
- #define icvBrushMax 5
- #define icvBRBack 3
- #define icvBRLTGray 4
-
-
- typedef COLORREF CV;
-
- // CoLoR Table
- typedef struct
- {
- CV rgcv[icvMax];
- } CLRT;
-
-
- // BRush Table
- typedef struct
- {
- HBRUSH mpicvhbr[icvBrushMax];
- } BRT;
-
-
- // DrawRec3d flags
- #define dr3Left 0x0001
- #define dr3Top 0x0002
- #define dr3Right 0x0004
- #define dr3Bot 0x0008
-
- #define dr3HackBotRight 0x1000 // code size is more important than aesthetics
- #define dr3All 0x000f
- typedef WORD DR3;
-
- #define BFCHECK 0x0003
- #define BFSTATE 0x0004
- #define BFFOCUS 0x0008
- #define BFINCLICK 0x0010 /* Inside click code */
- #define BFCAPTURED 0x0020 /* We have mouse capture */
- #define BFMOUSE 0x0040 /* Mouse-initiated */
- #define BFDONTCLICK 0x0080 /* Don't check on get focus */
-
- #define bpText 0x0002
- #define bpCheck 0x0004
- #define bpFocus 0x0008 // must be same as BFFOCUS
- #define bpBkgnd 0x0010
-
-
-
- //
- // Control Types
- // Commdlg types are necessary because commdlg.dll subclasses certain
- // controls before the app can call Ctl3dSubclassDlg.
- #define ctButton 0
- #define ctList 1
- #define ctEdit 2
- #define ctCombo 3
- #define ctStatic 4
- #define ctListCommdlg 5
- #define ctEditCommdlg 6
- #define ctMax 7
-
- // Windows Versions (Byte order flipped from GetWindowsVersion)
- #define ver30 0x0300
- #define ver31 0x030a
- #define ver40 0x0400
-
- // Border widths
- #define dxBorder 1
- #define dyBorder 1
-
- typedef struct
- {
- int xLeft;
- int yTop;
- int xRight;
- int yBot;
- } RC;
-
- int mpicvSysColor[] =
- {
- COLOR_BTNHIGHLIGHT,
- COLOR_BTNFACE,
- COLOR_BTNSHADOW,
- COLOR_BTNTEXT,
- COLOR_WINDOW,
- COLOR_WINDOWTEXT,
- COLOR_GRAYTEXT,
- COLOR_WINDOWFRAME
- };
-
-
- //Globals
- short sCntUsers = 0;
-
- WNDPROC wndprocEdit;
- WNDPROC wndprocButton;
- WNDPROC wndprocListBox;
- WNDPROC wndprocStatic;
- WNDPROC wndprocComboBox;
-
- DLGPROC dlgprocUty;
- WORD verWindows;
- HINSTANCE hinstLib;
- BOOL bRegistered = FALSE;
-
- HBITMAP hbmpCheckboxes;
- WORD grbitStyle = 0;
- #define bitFCoolButtons 0x0001
-
- #define Assert(f)
-
- char szEditClass[] = "Uty3D_Edit";
- char szButtonClass[] = "Uty3D_Button";
- char szListBoxClass[] = "Uty3D_ListBox";
- char szStaticClass[] = "Uty3D_Static";
- char szComboBoxClass[] = "Uty3D_ComboBox";
-
- char szDialogClass[] = "Uty3D_DLG";
-
- CLRT clrt;
- BRT brt;
-
-
- //Prototypes
-
- extern "C"
- {
- LRESULT _loadds FAR PASCAL EditWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
-
- LRESULT _loadds FAR PASCAL ButtonWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
-
- LRESULT _loadds FAR PASCAL ListBoxWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
-
- LRESULT _loadds FAR PASCAL StaticWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
-
- LRESULT _loadds FAR PASCAL ComboBoxWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
- LRESULT _loadds FAR PASCAL DialogProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam);
-
- } //extern "C"
-
- LONG ShareEditComboWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam,
- int ct);
-
- void Inval3dCtl(HWND hwnd,
- WINDOWPOS FAR *lpwp);
-
- void ListEditPaint3d(HWND hwnd,
- BOOL fEdit,
- int ct);
-
- void DrawInsetRect3d(HDC hdc,
- RC FAR *prc,
- DR3 dr3);
-
- void DrawRec3d(HDC hdc,
- RC FAR *lprc,
- ICV icvUL,
- ICV icvLR,
- DR3 dr3);
-
-
- VOID BtnPaint(HWND hwnd,
- HDC hdc,
- int bp);
-
- VOID DeleteBrushNull(HBRUSH FAR *ph);
- VOID DeleteObjects(VOID);
- BOOL RegisterClasses(HINSTANCE hInstance);
- VOID DrawPushButton(HWND hwnd,
- HDC hdc,
- RC FAR *lprc,
- LPSTR lpch,
- int cch,
- WORD bs,
- BOOL fDown);
-
- VOID MyGetTextExtent(HDC hdc,
- LPSTR lpsz,
- int FAR *lpdx,
- int FAR *lpdy);
-
- HBRUSH FAR PASCAL Ctl3dCtlColor(HDC hdc,
- LONG lParam);
-
- BOOL FUseWindowColors(HWND hwnd,
- int iType);
-
- LONG SharedListWndProc(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam,
- unsigned ct);
-
- VOID ClipCtlDc(HWND hwnd,
- HDC hdc);
-
- void StaticPaint(HWND hwnd,
- HDC hdc);
-
- void StaticPrint(HWND hwnd,
- HDC hdc,
- RC FAR *lprc,
- LONG style);
-
- BOOL ComboCreate(HWND hwndCombo,
- CREATESTRUCT FAR *pcs);
-
- /*******************************************************************
- Function: LibMain(
-
- Description:
-
- ********************************************************************/
-
- int CALLBACK LibMain( HINSTANCE hInstance, WORD , WORD wHeap, LPSTR )
- {
- hinstLib = hInstance;
-
- if (wHeap > 0)
- UnlockData( 0 );
-
-
-
- if (RegisterClasses(hInstance))
- {
- bRegistered = TRUE;
- }
- else
- {
- MessageBox(NULL, "Failed DLL Load", "Safe3D", MB_OK);
- return 0;
- }
-
- WORD wT = GetVersion();
- verWindows = (LOBYTE(wT) << 8) | HIBYTE(wT);
-
-
- return UtyCtlColorChange();
-
- //return 1;
- }
-
- /*******************************************************************
- Function: WEP(
-
- Description:
-
- ********************************************************************/
-
- int FAR PASCAL WEP(int )
- {
-
- if (bRegistered)
- {
- UnregisterClass(szEditClass, hinstLib);
- UnregisterClass(szButtonClass, hinstLib);
- UnregisterClass(szDialogClass, hinstLib);
- UnregisterClass(szListBoxClass, hinstLib);
- UnregisterClass(szStaticClass, hinstLib);
- UnregisterClass(szComboBoxClass, hinstLib);
- DeleteObjects();
- }
-
- return (1);
- }
-
- /*******************************************************************
- Function: EditWndProc3d(
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL EditWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
- {
-
- return ShareEditComboWndProc3d(hwnd, wm, wParam, lParam, ctEdit);
-
- }
-
- /*******************************************************************
- Function: ButtonWndProc3d
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL ButtonWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
- {
- //int ifrm3d;
- LONG lRet;
- LONG lStyle;
- PAINTSTRUCT ps;
- HDC hdc;
- int bf;
- int bfNew;
- int bp;
-
- switch(wm)
- {
- case BM_SETSTATE:
- case BM_SETCHECK:
- bp = bpCheck;
- goto DoIt;
- case WM_KILLFOCUS:
- // HACK! Windows will go into an infinit e loop trying to sync the
- // states of the AUTO_RADIOBUTTON in this group. (we turn off the
- // visible bit so it gets skipped in the enumeration)
- // Disable this code by clearing the STATE bit
- if ((((int) GetWindowLong(hwnd, GWL_STYLE)) & 0x1F) == BS_AUTORADIOBUTTON)
- SendMessage(hwnd, BM_SETSTATE, 0, 0L);
- bp = 0;
- goto DoIt;
- case WM_ENABLE:
- bp = bpCheck | bpText;
- goto DoIt;
- case WM_SETFOCUS:
- // HACK! if wParam == NULL we may be activated via the task manager
- // Erase background of control because a WM_ERASEBKGND messsage has not
- // arrived yet for the dialog
- bp = wParam == NULL ? (bpCheck | bpText | bpBkgnd) : (bpCheck | bpText);
- DoIt:
- bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
- if((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE)
- {
- SetWindowLong(hwnd, GWL_STYLE, lStyle & ~(WS_VISIBLE));
- lRet = CallWindowProc(wndprocButton, hwnd, wm, wParam, lParam);
- SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE)|WS_VISIBLE);
- bfNew = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
- if((wm != BM_SETSTATE && wm != BM_SETCHECK) ||
- bf != bfNew)
- {
- hdc = GetDC(hwnd);
- if (hdc != NULL)
- {
- Assert(BFFOCUS == bpFocus);
- /* If the check state changed, redraw no matter what,
- because it won't have during the above call to the def
- wnd proc */
- if ((bf & BFCHECK) != (bfNew & BFCHECK))
- bp |= bpCheck;
- ExcludeUpdateRgn(hdc, hwnd);
- BtnPaint(hwnd, hdc, bp|((bf^bfNew)&BFFOCUS));
- ReleaseDC(hwnd, hdc);
- }
- }
- return lRet;
- }
- break;
- case WM_PAINT:
- bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
- if ((hdc = (HDC) wParam) == NULL)
- hdc = BeginPaint(hwnd, &ps);
- if(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
- BtnPaint(hwnd, hdc, bpText|bpCheck|(bf&BFFOCUS));
- if (wParam == NULL)
- EndPaint(hwnd, &ps);
- return 0L;
- }
- return CallWindowProc(wndprocButton, hwnd, wm, wParam, lParam);
-
-
- }
-
- /*******************************************************************
- Function: ListBoxWndProc3d(
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL ListBoxWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam)
- {
- return SharedListWndProc(hwnd, wm, wParam, lParam, ctList);
- }
-
- /*******************************************************************
- Function: StaticWndProc3d(
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL StaticWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam)
- {
- HDC hdc;
- PAINTSTRUCT ps;
-
- switch (wm)
- {
- case WM_PAINT:
- if ((hdc = (HDC) wParam) == NULL)
- {
- hdc = BeginPaint(hwnd, &ps);
- ClipCtlDc(hwnd, hdc);
- }
- StaticPaint(hwnd, hdc);
- if (wParam == NULL)
- EndPaint(hwnd, &ps);
- return 0L;
- case WM_ENABLE:
- hdc = GetDC(hwnd);
- ClipCtlDc(hwnd, hdc);
- StaticPaint(hwnd, hdc);
- ReleaseDC(hwnd, hdc);
- return 0L;
- }
- return CallWindowProc(wndprocStatic, hwnd, wm, wParam, lParam);
-
- }
-
-
- /*******************************************************************
- Function: ComboBoxWndProc3d(
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL ComboBoxWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam)
- {
- LRESULT lRes;
- lRes = ShareEditComboWndProc3d(hwnd,
- wm,
- wParam,
- lParam,
- ctCombo);
-
-
-
- if (wm == WM_CREATE)
- {
- if (!ComboCreate(hwnd, (CREATESTRUCT FAR *)lParam))
- SetWindowLong(hwnd,
- GWL_WNDPROC,
- (LONG)wndprocComboBox);
- }
-
- return lRes;
-
- }
-
-
- /*******************************************************************
- Function: DialogProc3d(
-
- Description:
-
- ********************************************************************/
-
- LRESULT _loadds FAR PASCAL DialogProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam)
- {
- HBRUSH hbrush;
-
- switch (wm)
- {
- case WM_CTLCOLOR:
- hbrush = Ctl3dCtlColor((HDC)wParam, lParam);
- if (hbrush != (HBRUSH)FALSE)
- return (LRESULT)hbrush;
- break;
- }
-
- return CallWindowProc((WNDPROC)dlgprocUty, hwnd, wm, wParam, lParam);
- }
-
-
-
-
- /*******************************************************************
- Function: RegisterClasses
-
- Description:
-
- ********************************************************************/
-
- BOOL RegisterClasses(HINSTANCE hInstance)
- {
-
- WNDCLASS wc;
- //Edit
- if (!GetClassInfo(NULL, "Edit", &wc))
- return FALSE;
-
- wndprocEdit = wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = EditWndProc3d;
- wc.hInstance = hInstance;
- wc.lpszClassName = szEditClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
- //button
- if (!GetClassInfo(NULL, "Button", &wc))
- return FALSE;
-
- wndprocButton = wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = ButtonWndProc3d;
- wc.hInstance = hInstance;
- wc.lpszClassName = szButtonClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
- //listbox
- if (!GetClassInfo(NULL, "Listbox", &wc))
- return FALSE;
-
- wndprocListBox = wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = ListBoxWndProc3d;
- wc.hInstance = hInstance;
- wc.lpszClassName = szListBoxClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
- //Static
- if (!GetClassInfo(NULL, "Static", &wc))
- return FALSE;
-
- wndprocStatic = wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = StaticWndProc3d;
- wc.hInstance = hInstance;
- wc.lpszClassName = szStaticClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
-
- //Combobox
- if (!GetClassInfo(NULL, "ComboBox", &wc))
- return FALSE;
-
- wndprocComboBox = wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = ComboBoxWndProc3d;
- wc.hInstance = hInstance;
- wc.lpszClassName = szComboBoxClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
-
- //dialog class
- if (!GetClassInfo(NULL, WC_DIALOG, &wc))
- return FALSE;
-
- dlgprocUty = (DLGPROC)wc.lpfnWndProc;
-
- wc.style |= CS_GLOBALCLASS;
- wc.lpfnWndProc = DialogProc3d;
- wc.hInstance = hInstance;
- wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- wc.lpszClassName = szDialogClass;
-
- if (!RegisterClass(&wc))
- return FALSE;
-
-
- return TRUE;
-
-
-
- }
- /*******************************************************************
- Function: UtyCtlGetInstance();
-
- Description:
-
- ********************************************************************/
-
- HINSTANCE FAR PASCAL _export UtyCtlGetInstance()
- {
- return hinstLib;
- }
- /*******************************************************************
- Function: UtyCtlGetTemplate
-
- Description: Returns the template name for common dialogs
-
- ********************************************************************/
-
- PSZ FAR PASCAL _export UtyCtlGetTemplate(SHORT sTempId)
- {
- PSZ pszRet;
-
- switch(sTempId)
- {
- case UTY3DTEMP_OPENSAVE:
- pszRet = "Uty3D_Open";
- break;
- case UTY3DTEMP_COLOR:
- pszRet = "Uty3D_Color";
- break;
- case UTY3DTEMP_FONT:
- pszRet = "Uty3D_Font";
- break;
- case UTY3DTEMP_PRINT:
- pszRet = "Uty3D_Print";
- break;
- case UTY3DTEMP_PRINTSTUP:
- pszRet = "Uty3D_Prntstup";
- break;
- case UTY3DTEMP_FIND:
- pszRet = "Uty3D_Find";
- break;
- case UTY3DTEMP_REPLACE:
- pszRet = "Uty3D_Replace";
- break;
- default:
- pszRet = NULL;
- break;
- }
-
- return pszRet;
-
- }
-
- /*******************************************************************
- Function: UtyCtlWMCtlColor(
-
- Description:
-
- ********************************************************************/
-
- HBRUSH FAR PASCAL _export UtyCtlWMCtlColor(UINT ,
- WPARAM wParam,
- LPARAM lParam)
- {
- #ifdef WIN32
- Assert(WM_CTLCOLORMSGBOX < WM_CTLCOLORBTN);
- Assert(WM_CTLCOLOREDIT < WM_CTLCOLORBTN);
- Assert(WM_CTLCOLORLISTBOX < WM_CTLCOLORBTN);
- if(f3dDialogs)
- {
- if (wm >= WM_CTLCOLORLISTBOX)
- {
- if (wm == WM_CTLCOLORLISTBOX &&
- (GetWindow((HWND) lParam, GW_CHILD) == NULL ||
- (GetWindowLong((HWND) lParam, GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))
- {
- // if it doesn't have a child then it must be a list box
- // don't do brush stuff for drop down lists or else
- // it draws funny grey inside the edit rect
- return (HBRUSH) fFalse;
- }
- SetTextColor((HDC) wParam, clrt.rgcv[icvBtnText]);
- SetBkColor((HDC) wParam, clrt.rgcv[icvBtnFace]);
- return brt.mpicvhbr[icvBtnFace];
- }
- }
- return (HBRUSH) fFalse;
- #else
- return Ctl3dCtlColor((HDC)wParam, lParam);
- #endif
-
- }
-
- /*******************************************************************
- Function: UtyCtlGetVersion()
-
- Description:
-
- ********************************************************************/
-
- USHORT FAR PASCAL _export UtyCtlGetVersion(void)
- {
- return 0x0100;
- }
-
- /*
- HANDLE CALLBACK ColorBtnInfo( void ) // Provide info to dialog editor
- {
- HANDLE hCtlInfo;
- LPCTLINFO lpCtlInfo;
-
- hCtlInfo = GlobalAlloc( GHND, (DWORD)sizeof(CTLINFO) );
- if( hCtlInfo )
- {
- lpCtlInfo = (LPCTLINFO)GlobalLock( hCtlInfo );
- if( lpCtlInfo )
- {
- lpCtlInfo->wVersion = 100; // Generic version number
- lpCtlInfo->wCtlTypes = 1; // Single control, here
-
- lstrcpy( lpCtlInfo->szClass, CLASSNAME ); // Use class name for class
- lstrcpy( lpCtlInfo->szTitle, CLASSNAME ); // and title text
-
-
- lpCtlInfo->Type[ 0 ].wType = 0;
- lpCtlInfo->Type[ 0 ].wWidth = 129; // Set size
- lpCtlInfo->Type[ 0 ].wHeight = 65; // Initialize flags
- lpCtlInfo->Type[ 0 ].dwStyle = WS_CHILD | WS_TABSTOP;
-
- lstrcpy( lpCtlInfo->Type[ 0 ].szDescr, CLASSNAME );
- GlobalUnlock( hCtlInfo );
- }
- else
- {
- GlobalFree( hCtlInfo );
- hCtlInfo = NULL;
- }
- }
- return( hCtlInfo );
- }
-
-
-
-
- BOOL CALLBACK ColorBtnStyle( hWnd, hCtlStyle, lpfnVerifyId, lpfnGetIdStr )
- HWND hWnd;
- HANDLE hCtlStyle;
- LPFNSTRTOID lpfnVerifyId;
- LPFNIDTOSTR lpfnGetIdStr;
- {
- return( FALSE ); // No dialog...just return FALSE
- }
-
-
-
-
- WORD CALLBACK ColorBtnFlags( wFlags, lpszString, wMaxString )
- WORD wFlags;
- LPSTR lpszString;
- WORD wMaxString;
- {
- lpszString[ 0 ] = NULL; // These strings get written to the .DLG file
-
- return( lstrlen( lpszString ) ); // In effect, nothing gets written
- }
- */
-
-
-
- LONG ShareEditComboWndProc3d(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam,
- int ct)
- {
- LONG l;
-
- l = CallWindowProc((ct == ctEdit) ? wndprocEdit : wndprocComboBox,
- hwnd,
- wm,
- wParam,
- lParam);
-
- switch(wm)
- {
- case WM_WINDOWPOSCHANGING:
- if (verWindows >= ver31)
- Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
- break;
-
- case WM_PAINT:
- if (ct != ctCombo || (GetWindowLong(hwnd, GWL_STYLE) & 0x0003) != CBS_SIMPLE)
- ListEditPaint3d(hwnd, TRUE, ct);
- break;
- }
- return l;
- }
-
-
-
- void Inval3dCtl(HWND hwnd, WINDOWPOS FAR *lpwp)
- {
- RC rc;
- HWND hwndParent;
- LONG lStyle;
-
- GetWindowRect(hwnd, (LPRECT) &rc);
- lStyle = GetWindowLong(hwnd, GWL_STYLE);
- if (lStyle & WS_VISIBLE)
- {
- if (lpwp != NULL)
- {
- unsigned flags;
-
- // handle integral height listboxes (or any other control which
- // shrinks from the bottom)
- flags = lpwp->flags;
- if ((flags & (SWP_NOMOVE|SWP_NOSIZE)) == SWP_NOMOVE &&
- (lpwp->cx == (rc.xRight-rc.xLeft) && lpwp->cy <= (rc.yBot-rc.yTop)))
- rc.yTop = rc.yTop+lpwp->cy+1; // +1 to offset InflateRect
- }
- InflateRect((LPRECT) &rc, 1, 1);
- hwndParent = GetParent(hwnd);
- ScreenToClient(hwndParent, (LPPOINT) &rc);
- ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
- if(lStyle & WS_VSCROLL)
- rc.xRight ++;
- InvalidateRect(hwndParent, (LPRECT) &rc, FALSE);
- }
- }
-
-
- void ListEditPaint3d(HWND hwnd, BOOL fEdit, int ct)
- {
- CTLID id;
- RC rc;
- HDC hdc;
- HWND hwndParent;
- LONG lStyle;
- DR3 dr3;
-
- if(!((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE))
- return;
-
- if (fEdit)
- HideCaret(hwnd);
-
- GetWindowRect(hwnd, (LPRECT) &rc);
-
- ScreenToClient(hwndParent = GetParent(hwnd), (LPPOINT) &rc);
- ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
-
- hdc = GetDC(hwndParent);
-
- if(lStyle & WS_VSCROLL)
- dr3 = dr3All & ~dr3Right;
- else
- dr3 = dr3All;
- // don't draw the top if it's a listbox of a simple combo
-
- id = GetControlId(hwnd);
- if (id == (1000 + fEdit))
- {
- char szClass[20];
-
- GetClassName(hwndParent, szClass, sizeof(szClass));
- if (!lstrcmp(szClass, szComboBoxClass))
- {
- if (fEdit)
- {
- RC rcList;
- HWND hwndList;
- if ((GetWindowLong(hwndParent, GWL_STYLE) & 0x0003) == CBS_SIMPLE)
- {
- dr3 &= ~dr3Bot;
-
- hwndList = GetWindow(hwndParent, GW_CHILD);
- GetWindowRect(hwndList, (LPRECT) &rcList);
-
- // Some ugly stuff goin' on here!
- rc.xRight -= rcList.xRight-rcList.xLeft;
- DrawInsetRect3d(hdc, &rc, dr3Bot|dr3HackBotRight);
- rc.xRight += rcList.xRight-rcList.xLeft;
- }
- }
- else
- {
- rc.yTop++;
- dr3 &= ~dr3Top;
- }
- }
- }
-
- DrawInsetRect3d(hdc, &rc, dr3);
-
- if ((ct == ctCombo && (lStyle & 0x003) == CBS_DROPDOWNLIST))
- {
- rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
- DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Right|dr3Bot);
- }
- else if (lStyle & WS_VSCROLL)
- {
- rc.xRight++;
- DrawRec3d(hdc, &rc, icvForceWhite, icvForceWhite, dr3Right);
- rc.xRight--;
- rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
- DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Bot);
- }
-
- ReleaseDC(hwndParent, hdc);
- if (fEdit)
- ShowCaret(hwnd);
- }
-
-
- /*******************************************************************
- Function: DrawInsetRect3d(
-
- Description:
-
- ********************************************************************/
-
- void DrawInsetRect3d(HDC hdc,
- RC FAR *prc,
- DR3 dr3)
- {
- RC rc;
-
- rc = *prc;
- DrawRec3d(hdc, &rc, icvWindowFrame, icvForceLTGray, dr3 & dr3All);
- rc.xLeft--;
- rc.yTop--;
- rc.xRight++;
- rc.yBot++;
- DrawRec3d(hdc, &rc, icvForceDKGray, icvForceWhite, dr3);
- }
-
- /*******************************************************************
- Function: DrawRec3d(
-
- Description:
-
- ********************************************************************/
-
- void DrawRec3d(HDC hdc,
- RC FAR *lprc,
- ICV icvUL,
- ICV icvLR,
- DR3 dr3)
- {
- COLORREF cvSav;
- RC rc;
-
- cvSav = SetBkColor(hdc, clrt.rgcv[icvUL]);
-
- // top
- rc = *lprc;
- rc.yBot = rc.yTop+1;
- if (dr3 & dr3Top)
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
- (char far *) NULL, 0, (int far *) NULL);
-
- // left
- rc.yBot = lprc->yBot;
- rc.xRight = rc.xLeft+1;
- if (dr3 & dr3Left)
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
- (char far *) NULL, 0, (int far *) NULL);
-
- if (icvUL != icvLR)
- SetBkColor(hdc, clrt.rgcv[icvLR]);
-
- // right
- rc.xRight = lprc->xRight;
- rc.xLeft = rc.xRight-1;
- if (dr3 & dr3Right)
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
- (char far *) NULL, 0, (int far *) NULL);
-
- // bot
- if (dr3 & dr3Bot)
- {
- rc.xLeft = lprc->xLeft;
- rc.yTop = rc.yBot-1;
- if (dr3 & dr3HackBotRight)
- rc.xRight -=2;
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
- (char far *) NULL, 0, (int far *) NULL);
- }
-
- SetBkColor(hdc, cvSav);
- }
-
-
- /*******************************************************************
- Function: UtyCtlColorChange
-
- Description:
-
- ********************************************************************/
-
- BOOL FAR PASCAL _export UtyCtlColorChange(void)
- {
- ICV icv;
- CLRT clrtNew;
- HBITMAP hbmpCheckboxesNew;
- BRT brtNew;
-
- for (icv = 0; icv < icvSysMax; icv++)
- clrtNew.rgcv[icv] = GetSysColor(mpicvSysColor[icv]);
-
- //add forced colors to the table..
- clrtNew.rgcv[icvForceBlack] = RGB(0,0,0);
- clrtNew.rgcv[icvForceLTGray] = RGB(192,192,192);
- clrtNew.rgcv[icvForceDKGray] = RGB(128,128,128);
- clrtNew.rgcv[icvForceWhite] = RGB(255,255,255);
-
- if (verWindows == ver30)
- clrtNew.rgcv[icvBtnHilite] = RGB(0xff, 0xff, 0xff);
-
- if (clrtNew.rgcv[icvGrayText] == 0L || clrtNew.rgcv[icvGrayText] == clrtNew.rgcv[icvBtnFace])
- clrtNew.rgcv[icvGrayText] = RGB(0x80, 0x80, 0x80);
- if (clrtNew.rgcv[icvGrayText] == clrtNew.rgcv[icvBtnFace])
- clrtNew.rgcv[icvGrayText] = 0L;
-
- if (MEMICMP(&clrt, &clrtNew, sizeof(CLRT)))
- {
- hbmpCheckboxesNew = LoadUIBitmap(hinstLib, "D3",
- RGB(0,0,0), //clrtNew.rgcv[icvWindowText],
- RGB(192,192,192), //clrtNew.rgcv[icvBtnFace],
- RGB(128,128,128), //clrtNew.rgcv[icvBtnShadow],
- RGB(255,255,255), //clrtNew.rgcv[icvBtnHilite],
- RGB(255,255,255), //clrtNew.rgcv[icvWindow],
- clrtNew.rgcv[icvWindowFrame]);
-
- for (icv = 0; icv < icvSysBrushMax; icv++)
- brtNew.mpicvhbr[icv] = CreateSolidBrush(clrtNew.rgcv[icv]);
-
-
- brtNew.mpicvhbr[icvBRBack] = CreateSolidBrush(RGB(192,192,192));
-
- brtNew.mpicvhbr[icvBRLTGray] = CreateSolidBrush(RGB(192,192,192));
-
- for (icv = 0; icv < icvBrushMax; icv++)
- if (brtNew.mpicvhbr[icv] == NULL)
- goto OOM;
-
- if(hbmpCheckboxesNew != NULL)
- {
- DeleteObjects();
- brt = brtNew;
- clrt = clrtNew;
- hbmpCheckboxes = hbmpCheckboxesNew;
- return TRUE;
- }
- else
- {
- OOM:
- for (icv = 0; icv < icvBrushMax; icv++)
- DeleteBrushNull((HBRUSH FAR *)&brtNew.mpicvhbr[icv]);
- DeleteBrushNull((HBRUSH FAR *)&hbmpCheckboxesNew);
- return FALSE;
- }
- }
- return TRUE;
- }
-
- /*******************************************************************
- Function: UtyCtlMakeLink()
-
- Description: This function is only here for a program
- to call to force the linker to link in the dll.
-
- ********************************************************************/
-
- void FAR PASCAL _export UtyCtlMakeLink(void)
- {
- }
-
-
- /*******************************************************************
- Function: DeleteBrushNull(
-
- Description:
-
- ********************************************************************/
-
- VOID DeleteBrushNull(HBRUSH FAR *ph)
- {
- if (*ph != NULL)
- {
- DeleteObject(*ph);
- *ph = NULL;
- }
- }
-
- /*******************************************************************
- Function: DeleteObjects(
-
- Description:
-
- ********************************************************************/
-
- VOID DeleteObjects(VOID)
- {
- int icv;
-
- for(icv = 0; icv < icvBrushMax; icv++)
- DeleteBrushNull((HBRUSH FAR *)&brt.mpicvhbr[icv]);
- DeleteBrushNull((HBRUSH FAR *)&hbmpCheckboxes);
-
- }
-
-
- /*******************************************************************
- Function: BtnPaint(
-
- Description:
-
- ********************************************************************/
-
- VOID BtnPaint(HWND hwnd,
- HDC hdc,
- int bp)
- {
- RC rc;
- RC rcClient;
- HFONT hfont;
- int bs;
- int bf;
- HBRUSH hbrBtn;
- HWND hwndParent;
- int xBtnBmp;
- int yBtnBmp;
- HBITMAP hbmpSav;
- HDC hdcMem;
- char szTitle[256];
- int cch;
- BOOL fEnabled;
-
- bs = ((int) GetWindowLong(hwnd, GWL_STYLE)) & 0x1F;
- hwndParent = GetParent(hwnd);
- SetBkMode(hdc, OPAQUE);
- GetClientRect(hwnd, (LPRECT)&rcClient);
- rc = rcClient;
- if((hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
- hfont = (HFONT)SelectObject(hdc, hfont);
-
- hbrBtn = SEND_COLOR_BUTTON_MESSAGE(hwndParent, hwnd, hdc);
- hbrBtn = (HBRUSH)SelectObject(hdc, hbrBtn);
- IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
- if(bp & bpBkgnd && (bs != BS_GROUPBOX))
- PatBlt(hdc, rc.xLeft, rc.yTop, rc.xRight-rc.xLeft, rc.yBot-rc.yTop, PATCOPY);
-
- fEnabled = IsWindowEnabled(hwnd);
- bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
- yBtnBmp = 0;
- xBtnBmp = (((bf&BFCHECK) != 0) | ((bf&BFSTATE) >> 1)) * 14;
- if (!fEnabled)
- xBtnBmp += 14*(2+((bf&BFCHECK) != 0));
- if(bp & (bpText|bpFocus) ||
- bs == BS_PUSHBUTTON || bs == BS_DEFPUSHBUTTON)
- cch = GetWindowText(hwnd, szTitle, sizeof(szTitle));
- switch(bs)
- {
- #ifdef DEBUG
- default:
- Assert(fFalse);
- break;
- #endif
- case BS_PUSHBUTTON:
- case BS_DEFPUSHBUTTON:
- DrawPushButton(hwnd, hdc, &rcClient, szTitle, cch, bs, bf & BFSTATE);
- break;
-
- case BS_RADIOBUTTON:
- case BS_AUTORADIOBUTTON:
- yBtnBmp = 13;
- goto DrawBtn;
- case BS_3STATE:
- case BS_AUTO3STATE:
- Assert((BFSTATE >> 1) == 2);
- if((bf & BFCHECK) == 2)
- yBtnBmp = 26;
- // fall through
- case BS_CHECKBOX:
- case BS_AUTOCHECKBOX:
- DrawBtn:
- if(bp & bpCheck)
- {
- hdcMem = CreateCompatibleDC(hdc);
- if(hdcMem != NULL)
- {
- hbmpSav = (HBITMAP)SelectObject(hdcMem, hbmpCheckboxes);
- if(hbmpSav != NULL)
- {
- BitBlt(hdc, rc.xLeft, rc.yTop+(rc.yBot-rc.yTop-13)/2,
- 14, 13, hdcMem, xBtnBmp, yBtnBmp, SRCCOPY);
- SelectObject(hdcMem, hbmpSav);
- }
- DeleteDC(hdcMem);
- }
- }
- if(bp & bpText)
- {
- // BUG! this assumes we have only 1 hbm3dCheck type
- rc.xLeft = rcClient.xLeft + 14+4;
- // MyDrawText(hwnd, hdc, (LPSTR) szTitle, cch, &rc, DT_VCENTER|DT_LEFT|DT_SINGLELINE);
- if(!fEnabled)
- SetTextColor(hdc, clrt.rgcv[icvGrayText]);
- DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_VCENTER|DT_LEFT|DT_SINGLELINE);
- }
- if(bp & bpFocus)
- {
- int dx;
- int dy;
-
- rc.xLeft = rcClient.xLeft + 14+4;
-
- MyGetTextExtent(hdc, szTitle, &dx, &dy);
- rc.yTop = (rc.yBot-rc.yTop-dy)/2;
- rc.yBot = rc.yTop+dy;
- rc.xRight = rc.xLeft + dx;
-
- InflateRect((LPRECT) &rc, 1, 1);
- IntersectRect((LPRECT) &rc, (LPRECT) &rc, (LPRECT) &rcClient);
- DrawFocusRect(hdc, (LPRECT) &rc);
- }
- break;
- case BS_GROUPBOX:
- if(bp & (bpText|bpCheck))
- {
- int dy;
-
- dy = DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
-
- rcClient.yTop += dy/2;
- rcClient.xRight--;
- rcClient.yBot--;
- //DrawRec3d(hdc, &rcClient, icvBtnShadow, icvBtnShadow, dr3All);
- DrawRec3d(hdc, &rcClient, icvForceDKGray, icvForceDKGray, dr3All);
- OffsetRect((LPRECT) &rcClient, 1, 1);
- //DrawRec3d(hdc, &rcClient, icvBtnHilite, icvBtnHilite, dr3All);
- DrawRec3d(hdc, &rcClient, icvForceWhite, icvForceWhite, dr3All);
- rc.xLeft += 4;
- rc.xRight += 4;
- rc.yBot = rc.yTop+dy;
-
- if(!fEnabled)
- SetTextColor(hdc, clrt.rgcv[icvGrayText]);
- DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_LEFT|DT_SINGLELINE);
- }
- break;
- }
-
- SelectObject(hdc, hbrBtn);
- if(hfont != NULL)
- SelectObject(hdc, hfont);
- }
-
-
- /*******************************************************************
- Function: DrawPushButton(
-
- Description:
-
- ********************************************************************/
-
- VOID DrawPushButton(HWND hwnd,
- HDC hdc,
- RC FAR *lprc,
- LPSTR lpch,
- int cch,
- WORD bs,
- BOOL fDown)
- {
- //int dxyBrdr;
- int dxyShadow;
- HBRUSH hbrSav;
- RC rcInside;
- int dy;
- int dx;
- //LONG dwExt;
-
- rcInside = *lprc;
-
- if (!(grbitStyle & bitFCoolButtons))
- {
- DrawRec3d(hdc, lprc, icvWindowFrame, icvWindowFrame, dr3All);
- InflateRect((LPRECT) &rcInside, -1, -1);
- if (bs == LOWORD(BS_DEFPUSHBUTTON) && IsWindowEnabled(hwnd))
- {
- //dxyBrdr = 2;
- DrawRec3d(hdc, &rcInside, icvWindowFrame, icvWindowFrame, dr3All);
- InflateRect((LPRECT) &rcInside, -1, -1);
- }
- //else
- // dxyBrdr = 1;
-
- // Notch the corners
- PatBlt(hdc, lprc->xLeft, lprc->yTop, dxBorder, dyBorder, PATCOPY);
- /* Top xRight corner */
- PatBlt(hdc, lprc->xRight - dxBorder, lprc->yTop, dxBorder, dyBorder, PATCOPY);
- /* yBot xLeft corner */
- PatBlt(hdc, lprc->xLeft, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
- /* yBot xRight corner */
- PatBlt(hdc, lprc->xRight - dxBorder, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
- dxyShadow = 1 + !fDown;
- }
- else
- dxyShadow = 1;
-
- // draw upper left hilite/shadow
-
- if (fDown)
- hbrSav = (HBRUSH)SelectObject(hdc, brt.mpicvhbr[icvBtnShadow]);
- else
- hbrSav = (HBRUSH)SelectObject(hdc, brt.mpicvhbr[icvBtnHilite]);
-
- PatBlt(hdc, rcInside.xLeft, rcInside.yTop, dxyShadow,
- (rcInside.yBot - rcInside.yTop), PATCOPY);
- PatBlt(hdc, rcInside.xLeft, rcInside.yTop,
- (rcInside.xRight - rcInside.xLeft), dxyShadow, PATCOPY);
-
- // draw lower right shadow (only if not down)
- if (!fDown || (grbitStyle & bitFCoolButtons))
- {
- int i;
-
- if (fDown)
- SelectObject(hdc, brt.mpicvhbr[icvBtnHilite]);
- else
- SelectObject(hdc, brt.mpicvhbr[icvBtnShadow]);
- rcInside.yBot--;
- rcInside.xRight--;
-
- for (i = 0; i < dxyShadow; i++)
- {
- PatBlt(hdc, rcInside.xLeft, rcInside.yBot,
- rcInside.xRight - rcInside.xLeft + dxBorder, dyBorder,
- PATCOPY);
- PatBlt(hdc, rcInside.xRight, rcInside.yTop, dxBorder,
- rcInside.yBot - rcInside.yTop, PATCOPY);
- if (i < dxyShadow-1)
- InflateRect((LPRECT) &rcInside, -dxBorder, -dyBorder);
- }
- }
- // draw the button face
-
- rcInside.xLeft++;
- rcInside.yTop++;
-
- SelectObject(hdc, brt.mpicvhbr[icvBtnFace]);
- PatBlt(hdc, rcInside.xLeft, rcInside.yTop, rcInside.xRight-rcInside.xLeft,
- rcInside.yBot - rcInside.yTop, PATCOPY);
-
- // Draw the durned text
-
- if(!IsWindowEnabled(hwnd))
- SetTextColor(hdc, clrt.rgcv[icvGrayText]);
-
- MyGetTextExtent(hdc, lpch, &dx, &dy);
- rcInside.yTop += (rcInside.yBot-rcInside.yTop-dy)/2;
- rcInside.xLeft += (rcInside.xRight-rcInside.xLeft-dx)/2;
- rcInside.yBot = rcInside.yTop+dy;
- rcInside.xRight = rcInside.xLeft+dx;
-
- if (fDown)
- {
- OffsetRect((LPRECT) &rcInside, 1, 1);
- }
-
- DrawText(hdc, lpch, cch, (LPRECT) &rcInside, DT_LEFT|DT_SINGLELINE);
-
- if (hwnd == GetFocus())
- {
- InflateRect((LPRECT) &rcInside, 1, 1);
- IntersectRect((LPRECT) &rcInside, (LPRECT) &rcInside, (LPRECT) lprc);
- DrawFocusRect(hdc, (LPRECT) &rcInside);
- }
-
- if (hbrSav)
- SelectObject(hdc, hbrSav);
- }
-
-
- /*******************************************************************
- Function: MyGetTextExtent(
-
- Description:
-
- ********************************************************************/
-
- VOID MyGetTextExtent(HDC hdc,
- LPSTR lpsz,
- int FAR *lpdx,
- int FAR *lpdy)
- {
- char FAR *lpch;
- char szT[256];
-
- lpch = szT;
- while(*lpsz != '\000')
- {
- if (*lpsz == '&')
- {
- lpsz++;
- if (*lpsz == '\000')
- break;
- }
- *lpch++ = *lpsz++;
- }
- *lpch = '\000';
- #ifdef WIN32
- {
- PT pt;
-
- GetTextExtentPoint(hdc, lpsz, strlen(szT), &pt);
- *lpdx = pt.x;
- *lpdy = pt.y;
- }
- #else
- {
- long dwExt;
-
- dwExt = GetTextExtent(hdc, szT, lpch-(char far *)szT);
- *lpdx = LOWORD(dwExt);
- *lpdy = HIWORD(dwExt);
- }
- #endif
- }
-
- /*******************************************************************
- Function: Ctl3dCtlColor
-
- Description:
-
- ********************************************************************/
-
- HBRUSH FAR PASCAL Ctl3dCtlColor(HDC hdc,
- LONG lParam)
- {
- HWND hwndParent;
- #ifdef WIN32
- return (HBRUSH) fFalse;
- #else
- Assert(CTLCOLOR_MSGBOX < CTLCOLOR_BTN);
- Assert(CTLCOLOR_EDIT < CTLCOLOR_BTN);
- Assert(CTLCOLOR_LISTBOX < CTLCOLOR_BTN);
-
-
- if (HIWORD(lParam) >= CTLCOLOR_LISTBOX) //_EDIT & _MSGBOX fail here
- {
- if (HIWORD(lParam) == CTLCOLOR_LISTBOX &&
- (GetWindow((HWND)(LOWORD(lParam)), GW_CHILD) == NULL ||
- (GetWindowLong((HWND)(LOWORD(lParam)), GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))
- {
- // if it doesn't have a child then it must be a list box
- // don't do brush stuff for drop down lists or else
- // it draws funny grey inside the edit rect
- goto DefWP;
- }
- else if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
- goto DefWP;
- else if (FUseWindowColors((HWND)(LOWORD(lParam)), HIWORD(lParam)) )
- {
- SetTextColor(hdc, clrt.rgcv[icvBtnText]);
- SetBkColor(hdc, clrt.rgcv[icvBtnFace]);
- return brt.mpicvhbr[icvBtnFace];
- }
- else
- {
- SetTextColor(hdc, clrt.rgcv[icvForceBlack]);
- SetBkColor(hdc, clrt.rgcv[icvForceLTGray]);
- return brt.mpicvhbr[icvBRBack];
- }
- }
-
- DefWP:
- hwndParent = GetParent((HWND)(LOWORD(lParam)));
- if (hwndParent == NULL)
- return FALSE;
- return (HBRUSH)DefWindowProc(hwndParent, WM_CTLCOLOR, (WPARAM) hdc, (LONG) lParam);
- #endif
- }
-
-
- /*******************************************************************
- Function: FUseWindowColors(
-
- Description:
-
- ********************************************************************/
-
- BOOL FUseWindowColors(HWND hwnd,
- int iType)
- {
- int iStyle;
-
- if (iType == CTLCOLOR_BTN)
- {
- iStyle = ((int)GetWindowLong(hwnd, GWL_STYLE)) & 0x1f;
-
- if (iStyle == BS_PUSHBUTTON || iStyle == BS_DEFPUSHBUTTON)
- return TRUE;
- else
- return FALSE;
- }
-
- return FALSE;
- }
-
-
- /*******************************************************************
- Function: SharedListWndProc(
-
- Description:
-
- ********************************************************************/
-
- LONG SharedListWndProc(HWND hwnd,
- UINT wm,
- WPARAM wParam,
- LPARAM lParam,
- unsigned ct)
- {
- LONG l;
- switch(wm)
- {
- case WM_WINDOWPOSCHANGING:
- if (verWindows >= ver31)
- Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
- break;
- case WM_PAINT:
- l = CallWindowProc(wndprocListBox, hwnd, wm, wParam, lParam);
- ListEditPaint3d(hwnd, FALSE, ct);
- return l;
- }
- return CallWindowProc(wndprocListBox, hwnd, wm, wParam, lParam);
- }
-
-
- /*******************************************************************
- Function: ClipCtlDc(
-
- Description:
-
- ********************************************************************/
-
- VOID ClipCtlDc(HWND hwnd,
- HDC hdc)
- {
- RC rc;
-
- GetClientRect(hwnd, (LPRECT) &rc);
- IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
- }
-
- /*******************************************************************
- Function: StaticPaint(
-
- Description:
-
- ********************************************************************/
-
- void StaticPaint(HWND hwnd,
- HDC hdc)
- {
- LONG style;
- RC rc;
-
- style = GetWindowLong(hwnd, GWL_STYLE);
- if(!(style & WS_VISIBLE))
- return;
-
- GetClientRect(hwnd, (LPRECT) &rc);
- switch(style & 0x0f)
- {
- case SS_BLACKRECT:
- case SS_BLACKFRAME: // Inset rect
- DrawRec3d(hdc, &rc, icvForceDKGray, icvForceWhite, dr3All);
- break;
- case SS_GRAYRECT:
- case SS_GRAYFRAME:
- rc.xLeft++;
- rc.yTop++;
- DrawRec3d(hdc, &rc, icvForceWhite, icvForceWhite, dr3All);
- OffsetRect((LPRECT) &rc, -1, -1);
- DrawRec3d(hdc, &rc, icvForceDKGray, icvForceDKGray, dr3All);
- break;
- case SS_WHITERECT: // outset rect
- case SS_WHITEFRAME:
- DrawRec3d(hdc, &rc, icvForceWhite, icvForceDKGray, dr3All);
- break;
- case SS_LEFT:
- case SS_CENTER:
- case SS_RIGHT:
- case SS_LEFTNOWORDWRAP:
- {
- HFONT hfont;
- HBRUSH hbr;
-
- if((hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
- hfont = (HFONT)SelectObject(hdc, hfont);
- SetBkMode(hdc, OPAQUE);
-
- if(( hbr = SEND_COLOR_STATIC_MESSAGE(GetParent(hwnd), hwnd, hdc)) != NULL)
- hbr = (HBRUSH)SelectObject(hdc, hbr);
-
- StaticPrint(hwnd, hdc, (RC FAR *)&rc, style);
-
- if (hfont != NULL)
- SelectObject(hdc, hfont);
-
- if (hbr != NULL)
- SelectObject(hdc, hbr);
- }
- break;
- }
- }
-
- /*******************************************************************
- Function: StaticPrint(
-
- Description:
-
- ********************************************************************/
-
- void StaticPrint(HWND hwnd,
- HDC hdc,
- RC FAR *lprc,
- LONG style)
- {
- WORD dt;
- LONG cv;
- // int cch;
- char szText[256];
-
- PatBlt(hdc, lprc->xLeft, lprc->yTop, lprc->xRight-lprc->xLeft, lprc->yBot-lprc->yTop, PATCOPY);
-
-
- // if ((cch = GetWindowText(hwnd, szText, sizeof(szText))) == 0)
- if ( GetWindowText(hwnd, szText, sizeof(szText)) == 0)
- return;
-
- if ((style & 0x000f) == SS_LEFTNOWORDWRAP)
- dt = DT_NOCLIP | DT_EXPANDTABS;
- else
- {
- dt = DT_NOCLIP | DT_EXPANDTABS | DT_WORDBREAK | ((style & 0x000f)-SS_LEFT);
- }
-
- if (style & SS_NOPREFIX)
- dt |= DT_NOPREFIX;
-
- if (style & WS_DISABLED)
- cv = SetTextColor(hdc, clrt.rgcv[icvGrayText]);
-
- DrawText(hdc, szText, -1, (LPRECT) lprc, dt);
-
- // MyDrawText(hwnd, hdc, (LPSTR) szText, cch, lprc, dt);
-
- if (style & WS_DISABLED)
- cv = SetTextColor(hdc, cv);
- }
-
- /*******************************************************************
- Function: ComboCreate(
-
- Description:
-
- ********************************************************************/
-
- BOOL ComboCreate(HWND hwndCombo,
- CREATESTRUCT FAR *pcs)
- {
-
- HWND hwndEdit;
- HWND hwndList;
-
- if ((pcs->style & 0x0003) == CBS_SIMPLE)
- {
- hwndList = GetWindow(hwndCombo, GW_CHILD);
- if (hwndList != NULL)
- {
- //subclass edit and list along with the combo for simple
- SetWindowLong(hwndList,
- GWL_WNDPROC,
- (LONG)ListBoxWndProc3d);
- hwndEdit = GetWindow(hwndList, GW_HWNDNEXT);
- if (hwndEdit != NULL)
- SetWindowLong(hwndEdit,
- GWL_WNDPROC,
- (LONG)EditWndProc3d);
- return TRUE;
- }
- return FALSE;
- }
- else if ((pcs->style & 0x0003) == CBS_DROPDOWN)
- {
- // Subclass edit so bottom border of the edit draws properly.
- // This case is specially handled in ListEditPaint3d
- // The combo will not be subclassed
- hwndEdit = GetWindow(hwndCombo, GW_CHILD);
- if (hwndEdit != NULL)
- SetWindowLong(hwndEdit,
- GWL_WNDPROC,
- (LONG)EditWndProc3d);
- return FALSE;
- }
- return TRUE; //dropdown lists
-
- }
-
-